var ListUtil = new Object();
ListUtil.getSelectedIndexes = function(oListbox) {
	var arrIndexes = new Array();

	for (var i = 0; i < oListbox.options.length; i++) {
		if (oListbox.options[i].selected) {
			arrIndexes.push(i);
		}
	}
	return arrIndexes;
}
ListUtil.add = function(oListbox, sName, sValue) {
	var oOption = document.createElement("option");
	oOption.appendChild(document.createTextNode(sName));

	if (arguments.length == 3) {
		oOption.setAttribute("value", sValue);
		// oOption.value = sValue;
	}

	oListbox.appendChild(oOption);
}

ListUtil.remove = function(oListbox, iIndex) {
	oListbox.remove(iIndex);
}
ListUtil.move = function(oListboxFrom, oListboxTo, iIndex) {
	var oOption = oListboxFrom.options[iIndex];

	if (oOption != null)
		oListboxTo.appendChild(oOption);
}
ListUtil.shiftUp = function(oListbox, iIndex) {
	if (iIndex > 0) {
		var oOption = oListbox.options[iIndex];
		var oPrevOption = oListbox.options[iIndex - 1];
		oListbox.insertBefore(oOption, oPrevOption);
	}
}
ListUtil.shiftDown = function(oListbox, iIndex) {
	if (iIndex < oListbox.options.length - 1) {
		var oOption = oListbox.options[iIndex];
		var oNextOption = oListbox.options[iIndex + 1];
		oListbox.insertBefore(oNextOption, oOption);
	}
}
function show(id) {
	document.getElementById(id).style.display = "";
}
function hide(id) {
	document.getElementById(id).style.display = "none";
}
function toggle(id) {
	if (!isShow(id))
		show(id);
	else
		hide(id);
}
function isShow(id) {
	return document.getElementById(id).style.display == "";
}
function submitSort(sort) {
	document.forms[0].sort.value = sort;
	document.forms[0].submit();
}
function submitPage(pageNo) {
	document.forms[0].pageNo.value = pageNo;
	document.forms[0].submit();
}
function digitDotOnly(elem) {
	elem.value = elem.value.replace(/[^\d.]+/g, "");
}
function digitOnly(elem) {
	elem.value = elem.value.replace(/[^\d]+/g, "");
}
function gotoPage() {
	document.forms[0].pageNo.value = document.getElementById("gotoPageText").value;
	document.forms[0].submit();
}
function enterPage(e) {
	digitOnly(document.getElementById("gotoPageText"));
	var currKey = 0;
	var e = e||event;
	if (e.keyCode==13) {
		gotoPage();
	}
}
function trimString(str) {
	return str.replace(/^\s+|\s+$/g, "");
}
function getYMD(date) {
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var monthStr = month > 9 ? "" + month : "0" + month;
	var day = date.getDate();
	var dayStr = day > 9 ? "" + day : "0" + day;
	return year + "-" + monthStr + "-" + dayStr;
}
function getYMDHMS(date) {
	var hour = date.getHours();
	var hourStr = hour > 9 ? "" + hour : "0" + hour;
	var minute = date.getMinutes();
	var minuteStr = minute > 9 ? "" + minute : "0" + minute;
	var second = date.getSeconds();
	var secondStr = second > 9 ? "" + second : "0" + second;
	return getYMD(date) + " " + hourStr + ":" + minuteStr + ":" + secondStr;
}
//myField accepts an object reference, myValue accepts the text strint to add
function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();
		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//Mozilla/Firefox/Netscape 7+ support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		
		//Here we get the start and end points of the
		//selection. Then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//Then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}
function changeSelectAll(parentCheck, childrenID) {
	return function() {
		document.getElementById(parentCheck).checked = isSelectAll(childrenID);
	}
}
function addCheckboxClickEvent(parentCheck, childrenID) {
	var elems = document.getElementById(childrenID).getElementsByTagName("input");
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].type == "checkbox")
			elems[i].onclick = changeSelectAll(parentCheck, childrenID);
	}
	document.getElementById(parentCheck).onclick = selectDeselectAll(document.getElementById(parentCheck), document.getElementById(childrenID));
}

function selectDeselectAll(parentCheck, childrenID) {
	return function() {
		selectAll(childrenID, parentCheck.checked);
	}
}

function isSelectAll(id) {
	var elems = document.getElementById(id).getElementsByTagName("input");
	for (var i = 0; i < elems.length; i++) {
		if (elems[i].type == "checkbox" && !elems[i].checked) {
			return false;
		}
	}
	return true;
}
function selectAll(elem, flag) {
	var length = elem.childNodes.length;
	for (var i = 0; i < length; i++) {
		var child = elem.childNodes[i];
		if ("checkbox" == child.type && !child.disabled) {
			child.checked = flag;
		}
		selectAll(child, flag);
	}
}
function isSelectCheckChild(id) {
	var elems = document.getElementById(id).getElementsByTagName("input");
	for (var i = 0; i < elems.length; i++)
		if (elems[i].type == "checkbox" && elems[i].checked)
			return true
	return false;
}
function submitDelete(path, specForm) {
	if (isSelectCheckChild("checkboxes")) {
		if (confirm('您确定要做此操作吗？')) {
			specForm.action = path;
			specForm.submit();
		}
	} else {
		show("selectFirst");
		if (document.getElementById("pErrorInfo"))
			hide("pErrorInfo");
	}
}
function deleteConfirm(path) {
	if (confirm('您确定要做此操作吗？'))
		location.href = path;
}
function moveOption(orig, target, isSelected) {
	var indexArray = [];
	for(var i = 0; i < orig.options.length; i++) {
	if (isSelected && !orig.options[i].selected)
		continue;
	var j = 0;
	for(; j < target.options.length; j++) {
		if (target.options[j].value == orig.options[i].value)
			break;
	}
	if (j >= target.options.length)
		indexArray.push(i);
	}
	for(idx in indexArray)
		ListUtil.add(target, orig.options[indexArray[idx]].text, orig.options[indexArray[idx]].value);
}
function privLeftToRightAll() {
	var leftSelect = document.forms[0].privLeft;
	var rightSelect = document.forms[0].privRight;
	moveOption(leftSelect, rightSelect);
}
function privLeftToRight() {
	var leftSelect = document.forms[0].privLeft;
	var rightSelect = document.forms[0].privRight;
	moveOption(leftSelect, rightSelect, true);
}
function privRightToLeftAll() {
	var rightSelect = document.forms[0].privRight;
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
		rightSelect.remove(i);
}
function privRightToLeft() {
	var rightSelect = document.forms[0].privRight;
	var idxArray = [];
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
	if (rightSelect.options[i].selected)
		idxArray.push(i);
	for (idx in idxArray)
		rightSelect.remove(idxArray[idx]);
}
//复制到剪贴板
function copyToClipboard(txt){
	//IE
	if(window.clipboardData){
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", txt);
		alert("复制成功！");
	}
	//Firefox
	else if(window.netscape){
		try{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}catch(e){
			alert("被浏览器拒绝！n请在浏览器地址栏输入'about:config'并回车n然后将'signed.applets.codebase_principal_support'设置为'true'");
		}
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if(!clip){
			return;
		}
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans){
			return;
		}
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext = txt;
		str.data = copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if (!clip){
			return false;
		}
		clip.setData(trans,null,clipid.kGlobalClipboard);
		alert("复制成功！");
	}
}
function setRolePermission() {
	var rightSelect = document.forms[0].privRight;
	var valueArray = [];
	for (var i = 0; i < rightSelect.options.length; i++)
		valueArray.push(rightSelect.options[i].value);
	document.forms[0].rolePermission.value = valueArray.join(",");
}
function roleCreate() {
	var nameElem = document.forms[0].name;
	var value = nameElem.value;
	value = trimString(value);
	if (value == "") {
		show("nameNotEmpty");
		nameElem.focus();
		nameElem.select();
		return false;
	}
	setRolePermission();
	return true;
}
function dealNamePrompt() {
	var nameElem = document.forms[0].name;
	var value = nameElem.value;
	value = trimString(value);
	if (!value == "")
		hide("nameNotEmpty");
}
function registerHideUsernameTip() {
	if (isShow("usernameNotEmpty"))
		hide("usernameNotEmpty");
	if (isShow("usernameLength"))
		hide("usernameLength");
	if (isShow("usernameError"))
		hide("usernameError");
	if (isShow("usernameNotRepeat"))
		hide("usernameNotRepeat");
}
function dealNickPrompt() {
	var elem = document.forms[0].nick;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("nickNotEmpty");
}
function dealWangwangIdPrompt() {
	var elem = document.forms[0].wangwangId;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("wangwangIdNotEmpty");
}
function dealWangwangNickPrompt() {
	var elem = document.forms[0].wangwangNick;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("wangwangIdNotEmpty");
}
function checkUsernameRepeat(path, id) {
	var value = document.getElementById("username").value;
	value = trimString(value);
	if (value == "") {
		show("usernameNotEmpty");
		return;
	}
	if (!/^[\da-zA-Z]{6,20}$/.test(value)) {
		show("usernameLength");
		return;
	}
	var tmpPath = path + "?username=" + document.getElementById("username").value;
	if (id)
		tmpPath += "&id=" + id;
	tmpPath += "&date=" + new Date();
	$.ajax({
		url: tmpPath,
		dataType: "json",
		beforeSend: function() {
			show("loading");
		},
		success: function(data, textStatus, xmlHttp) {
			hide("loading");
			if (data.repeat == "True")
			show("usernameError");
			else
			show("usernameNotRepeat");
		},
		complete: function() {
			hide("loading");
		}
	});
}
function selectSex(selectValue) {
	var sexArr = document.forms[0].sex;
	for(var i = 0; i < sexArr.length; i++) {
		if (sexArr[i].value == selectValue) {
			sexArr[i].checked = true;
			break;
		}
	}
}
function roleLeftToRightAll() {
	var leftSelect = document.forms[0].roleLeft;
	var rightSelect = document.forms[0].roleRight;
	moveOption(leftSelect, rightSelect);
}
function roleLeftToRight() {
	var leftSelect = document.forms[0].roleLeft;
	var rightSelect = document.forms[0].roleRight;
	moveOption(leftSelect, rightSelect, true);
}
function roleRightToLeftAll() {
	var rightSelect = document.forms[0].roleRight;
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
		rightSelect.remove(i);
}
function roleRightToLeft() {
	var rightSelect = document.forms[0].roleRight;
	var idxArray = [];
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
	if (rightSelect.options[i].selected)
		idxArray.push(i);
	for (idx in idxArray)
		rightSelect.remove(idxArray[idx]);
}
function setUserRole() {
	var rightSelect = document.forms[0].roleRight;
	var valueArray = [];
	for (var i = 0; i < rightSelect.options.length; i++)
		valueArray.push(rightSelect.options[i].value);
	document.forms[0].role.value = valueArray.join(",");
}
function userCreate() {
	var elem = document.forms[0].username;
	if (elem) {
	    var value = elem.value;
	    value = trimString(value);
	    if (value == "") {
		show("usernameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	    } else if (!/^[\da-zA-Z]{6,20}$/.test(value)) {
		show("usernameLength");
		document.getElementById("username").focus();
		document.getElementById("username").select();
		return false;
	    }
	}
	var elem = document.forms[0].nick;
	if (elem) {
	    var value = elem.value;
	    value = trimString(value);
	    if (value == "") {
		show("nickNotEmpty");
		elem.focus();
		elem.select();
		return false;
	    }
	}
	setUserRole();
	return true;
}
function faqCreate() {
	var questionElem = document.forms[0].question;
	var value = questionElem.value;
	value = trimString(value);
	if (value == "") {
		show("questionNotEmpty");
		questionElem.focus();
		questionElem.select();
		return false;
	} else if (value.length > 150) {
		show("questionLengthNotValid");
		questionElem.focus();
		questionElem.select();
		return false;
	}
	var answerElem = document.forms[0].answer;
	var value = answerElem.value;
	value = trimString(value);
	if (value == "") {
		show("answerNotEmpty");
		answerElem.focus();
		answerElem.select();
		return false;
	} else if (value.length > 500) {
		show("answerLengthNotValid");
		answerElem.focus();
		answerElem.select();
		return false;
	}
	return true;
}
function dealQuestionPrompt() {//150
	var questionElem = document.forms[0].question;
	var value = questionElem.value;
	value = trimString(value);
	if (value != "")
		hide("questionNotEmpty");
	if (value.length > 150)
		hide("questionLengthNotValid");
}
function dealAnswerPrompt() {//500
	var answerElem = document.forms[0].answer;
	var value = answerElem.value;
	value = trimString(value);
	if (value != "")
		hide("answerNotEmpty");
	if (value.length > 150)
		hide("answerLengthNotValid");
}
function feedbackCreate() {
	var elem = document.forms[0].name;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("nameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
// complain create
function complainCreate() {
	var nickElem = document.forms[0].nick;
	var value = nickElem.value;
	value = trimString(value);
	if (value == "") {
		show("nickNotEmpty");
		nickElem.focus();
		nickElem.select();
		return false;
	}
	var feedbackElem = document.forms[0].feedback;
	var value = feedbackElem.value;
	value = trimString(value);
	if (value == "") {
		show("feedbackNotEmpty");
		feedbackElem.focus();
		return false;
	}
	var contentElem = document.forms[0].content;
	var value = contentElem.value;
	value = trimString(value);
	if (value == "") {
		show("contentNotEmpty");
		contentElem.focus();
		contentElem.select();
		return false;
	} else if (value.length > 500) {
		show("contentLengthNotValid");
		contentElem.focus();
		contentElem.select();
		return false;
	}
	return true;
}
function dealContentPrompt() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("contentNotEmpty");
	if (value.length <= 500)
		hide("contentLengthNotValid");
}
function dealFeedbackPrompt() {
	var elem = document.forms[0].feedback;
	var value = elem.value;
	value = trimString(value);
	if (value)
		hide("feedbackNotEmpty");
}
// handle reason
function dealHandleReasonPrompt() {
	var elem = document.forms[0].handleReason;
	var value = elem.value;
	value = trimString(value);
	if (value)
		hide("handleReasonNotEmpty");
	if (value.length <= 500)
		hide("handleReasonLengthNotValid");
}
function dealComplainSubmit() {
	var elem = document.forms[0].handleReason;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("handleReasonNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 500) {
		show("handleReasonLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}




//username prompt
function dealUsernamePrompt() {
	var elem = document.forms[0].username;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("usernameNotEmpty");
	}
	if (document.getElementById("usernameError") && isShow("usernameError"))
		hide("usernameError");
}
function dealReturnvisitContentPrompt() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("contentNotEmpty");
	if (value.length <= 2000)
		hide("contentLengthNotValid");
}
function returnvisitCreate() {
	var elem = document.forms[0].username;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("usernameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("contentNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 2000) {
		show("contentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function showHideTimeByHand() {
	if (document.getElementById("timeByHand").checked) {
		show("timeByHandTBody");
		document.getElementById("timeArea").disabled = true;
	}
	else {
		document.getElementById("timeArea").disabled = false;
		hide("timeByHandTBody");
	}
}
function picStatSubmit() {
	if (document.getElementById("timeByHand").checked) {
		var beginTime1Value = document.getElementById("beginTime1").value;
		var endTime1Value = document.getElementById("endTime1").value;
		if (beginTime1Value && !endTime1Value) {
			show("endTime1NotEmpty");
			return false;
		} else if (endTime1Value && !beginTime1Value) {
			show("beginTime1NotEmpty");
			return false;
		}
		
		var beginTime2Value = document.getElementById("beginTime2").value;
		var endTime2Value = document.getElementById("endTime2").value;
		if (beginTime2Value && !endTime2Value) {
			show("endTime2NotEmpty");
			return false;
		} else if (endTime2Value && !beginTime2Value) {
			show("beginTime2NotEmpty");
			return false;
		}
		
		var beginTime3Value = document.getElementById("beginTime3").value;
		var endTime3Value = document.getElementById("endTime3").value;
		if (beginTime3Value && !endTime3Value) {
			show("endTime3NotEmpty");
			return false;
		} else if (endTime3Value && !beginTime3Value) {
			show("beginTime3NotEmpty");
			return false;
		}
		
		var beginTime4Value = document.getElementById("beginTime4").value;
		var endTime4Value = document.getElementById("endTime4").value;
		if (beginTime4Value && !endTime4Value) {
			show("endTime4NotEmpty");
			return false;
		} else if (endTime4Value && !beginTime4Value) {
			show("beginTime4NotEmpty");
			return false;
		}
	}
	return true;
}
function dealBeginTime1Prompt() {
	var elem = document.forms[0].beginTime1;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("beginTime1NotEmpty");
}
function dealEndTime1Prompt() {
	var elem = document.forms[0].endTime1;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("endTime1NotEmpty");
}
function dealBeginTime2Prompt() {
	var elem = document.forms[0].beginTime2;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("beginTime2NotEmpty");
}
function dealEndTime2Prompt() {
	var elem = document.forms[0].endTime2;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("endTime2NotEmpty");
}
function dealBeginTime3Prompt() {
	var elem = document.forms[0].beginTime3;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("beginTime3NotEmpty");
}
function dealEndTime3Prompt() {
	var elem = document.forms[0].endTime3;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("endTime3NotEmpty");
}
function dealBeginTime4Prompt() {
	var elem = document.forms[0].beginTime4;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("beginTime4NotEmpty");
}
function dealEndTime4Prompt() {
	var elem = document.forms[0].endTime4;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("endTime4NotEmpty");
}
function dealBeginScorePrompt() {
	var elem = document.forms[0].beginScore;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("beginScoreNotEmpty");
		if (judgeInt(value))
			hide("beginScoreDigit");
	}
}
function dealEndScorePrompt() {
	var elem = document.forms[0].endScore;
	var value = elem.value;
	value = trimString(value);
	if (!value || judgeInt(value))
		hide("endScoreDigit");
}
function dealDiscountPrompt() {
	var elem = document.forms[0].discount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("discountNotEmpty");
		if (judgeFloat(value))
			hide("discountDigit");
	}
}
function judgeFloat(value) {
    return /^\d+$|^\d+(\.\d*)?$/.test(value);
}
function judgeInt(value) {
	return /^\d+$/.test(value);
}
function judgeAllInt(value) {
	return /^[-\d]+$/.test(value);
}
function intelevelCreate() {
	var nameElem = document.forms[0].name;
	var value = nameElem.value;
	value = trimString(value);
	if (!value) {
		show("nameNotEmpty");
		nameElem.focus();
		nameElem.select();
		return false;
	}

	var elem = document.forms[0].beginScore;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("beginScoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeInt(value)) {
		show("beginScoreDigit");
		elem.focus();
		elem.select();
		return false;
	}

	var elem = document.forms[0].endScore;
	var value = elem.value;
	value = trimString(value);
	if (value && !judgeInt(value)) {
		show("endScoreDigit");
		elem.focus();
		elem.select();
		return false;
	}

	var elem = document.forms[0].discount;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("discountNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeFloat(value)) {
		show("discountDigit");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function dealScorePrompt() {
	var elem = document.forms[0].score;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("scoreNotEmpty");
		if (judgeInt(value))
			hide("scoreDigit");
	}
}
function dealConsumePrompt() {
	var elem = document.forms[0].consume;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("consumeNotEmpty");
		if (judgeInt(value))
			hide("consumeDigit");
	}
}
function intesettingCreate() {
	var nameElem = document.forms[0].name;
	if (nameElem) {
		var value = nameElem.value;
		value = trimString(value);
		if (!value) {
			show("nameNotEmpty");
			nameElem.focus();
			nameElem.select();
			return false;
		}
	}

	var elem = document.forms[0].consume;
	if (elem) {
	    var value = elem.value;
	    value = trimString(value);
	    if (!value) {
		show("consumeNotEmpty");
		elem.focus();
		elem.select();
		return false;
	    }
	    if (!judgeAllInt(value)) {
		show("consumeDigit");
		elem.focus();
		elem.select();
		return false;
	    }
	}

	var elem = document.forms[0].score;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("scoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeAllInt(value)) {
		show("scoreDigit");
		elem.focus();
		elem.select();
		return false;
	}

	return true;
}
function customerCreate() {
	var elem = document.forms[0].nick;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("nickNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}

	return true;
}
function integrationCreate() {
	var elem = document.forms[0].username;
	if (elem) {
	    var value = elem.value;
	    value = trimString(value);
	    if (!value) {
		show("usernameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	    }
	}

	var elem = document.forms[0].score;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("scoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else {
		if (!judgeAllInt(value)) {
			show("scoreDigit");
			elem.focus();
			elem.select();
			return false;
		}
	}

	var elem = document.forms[0].remark;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (value.length > 150) {
			show("remarkLength");
			elem.focus();
			elem.select();
			return false;
		}
	}

	return true;
}
function dealRemarkPrompt() {
	var elem = document.forms[0].remark;
	var value = elem.value;
	value = trimString(value);
	if (value) {
	if (value.length <= 150)
		hide("remarkLength");
	}
}
function customerSearch() {
	var elem = document.forms[0].username;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("usernameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}

	return true;
}
function chatRecordExcelSubmit() {
	document.forms['excelForm'].userId.value = document.forms[0].userId.value;
	document.forms['excelForm'].toId.value = document.forms[0].toId.value;
	document.forms['excelForm'].beginTime.value = document.forms[0].beginTime.value;
	document.forms['excelForm'].endTime.value = document.forms[0].endTime.value;
	document.forms['excelForm'].content.value = document.forms[0].content.value;
	document.forms['excelForm'].submit();
}
function tradeStatExcelSubmit() {
	if (!tradeStatSubmit())
	    return;
	document.forms['excelForm'].sort.value = document.forms[0].sort.value;
	document.forms['excelForm'].tradeCountBegin.value = document.forms[0].tradeCountBegin.value;
	document.forms['excelForm'].tradeCountEnd.value = document.forms[0].tradeCountEnd.value;
	document.forms['excelForm'].tradeNumBegin.value = document.forms[0].tradeNumBegin.value;
	document.forms['excelForm'].tradeNumEnd.value = document.forms[0].tradeNumEnd.value;
	document.forms['excelForm'].tradePaymentBegin.value = document.forms[0].tradePaymentBegin.value;
	document.forms['excelForm'].tradePaymentEnd.value = document.forms[0].tradePaymentEnd.value;
	document.forms['excelForm'].beginTime.value = document.forms[0].beginTime.value;
	document.forms['excelForm'].endTime.value = document.forms[0].endTime.value;
	document.forms['excelForm'].submit();
}
function tradeStatSubmit() {
	var elem = document.forms[0].tradeCountBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeInt(value);
	if (!isBeginInt) {
	    show("tradeCountNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	var elem = document.forms[0].tradeCountEnd;
	var value = elem.value;
	var isEndInt = !value || judgeInt(value);
	if (!isEndInt) {
	    show("tradeCountNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	var elem = document.forms[0].tradeNumBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeInt(value);
	if (!isBeginInt) {
	    show("tradeNumNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	var elem = document.forms[0].tradeNumEnd;
	var value = elem.value;
	var isEndInt = !value || judgeInt(value);
	if (!isEndInt) {
	    show("tradeNumNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	var elem = document.forms[0].tradePaymentBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeFloat(value);
	if (!isBeginInt) {
	    show("tradePaymentNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	var elem = document.forms[0].tradePaymentEnd;
	var value = elem.value;
	var isEndInt = !value || judgeFloat(value);
	if (!isEndInt) {
	    show("tradePaymentNotValid");
	    elem.focus();
	    elem.select();
	    return false;
	}

	return true;
}
function dealTradeCountPrompt() {
	var elem = document.forms[0].tradeCountBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeInt(value);
	
	var elem = document.forms[0].tradeCountEnd;
	var value = elem.value;
	var isEndInt = !value || judgeInt(value);

	if (isBeginInt && isEndInt)
	    hide("tradeCountNotValid");
}
function dealTradeNumPrompt() {
	var elem = document.forms[0].tradeNumBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeInt(value);
	
	var elem = document.forms[0].tradeNumEnd;
	var value = elem.value;
	var isEndInt = !value || judgeInt(value);

	if (isBeginInt && isEndInt)
	    hide("tradeNumNotValid");
}
function dealTradePaymentPrompt() {
	var elem = document.forms[0].tradePaymentBegin;
	var value = elem.value;
	var isBeginInt = !value || judgeFloat(value);
	
	var elem = document.forms[0].tradePaymentEnd;
	var value = elem.value;
	var isEndInt = !value || judgeFloat(value);

	if (isBeginInt && isEndInt)
	    hide("tradePaymentNotValid");
}
function rewardSettingCreate() {
	var nameElem = document.forms[0].name;
	var value = nameElem.value;
	value = trimString(value);
	if (!value) {
		show("nameNotEmpty");
		nameElem.focus();
		nameElem.select();
		return false;
	}

	var elem = document.forms[0].score;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("scoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeAllInt(value)) {
		show("scoreDigit");
		elem.focus();
		elem.select();
		return false;
	}

	return true;
}
// 更改工作奖惩设置
function changeRewardSetting() {
	// getScoreDict写在页面上,由程序动态生成
	var scoreDict = getScoreDict();
	var selectValue = document.forms[0].rewardSetting.value;
	if (scoreDict[selectValue])
		document.forms[0].score.value = scoreDict[selectValue];
	else
		document.forms[0].score.value = "";
	if (selectValue != "-1")
		hide("rewardSettingNotEmpty");
}
function dealUserIdPrompt() {
	var elem = document.forms[0].userId;
	var value = elem.value;
	value = trimString(value);
	if (value != "-1")
	hide("userIdNotEmpty");
}
function rewardCreate() {
	var elem = document.forms[0].userId;
	var value = elem.value;
	value = trimString(value);
	if (value == "-1") {
		show("userIdNotEmpty");
		elem.focus();
		return false;
	}

	var elem = document.forms[0].rewardSetting;
	var value = elem.value;
	value = trimString(value);
	if (value == "-1") {
		show("rewardSettingNotEmpty");
		elem.focus();
		return false;
	}

	var elem = document.forms[0].score;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("scoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else {
		if (!judgeAllInt(value)) {
			show("scoreDigit");
			elem.focus();
			elem.select();
			return false;
		}
	}

	var elem = document.forms[0].remark;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (value.length > 150) {
			show("remarkLength");
			elem.focus();
			elem.select();
			return false;
		}
	}

	return true;
}
function rewardExcelSubmit() {
	document.forms['excelForm'].userId.value = document.forms[0].userId.value;
	document.forms['excelForm'].rewardSetting.value = document.forms[0].rewardSetting.value;
	document.forms['excelForm'].beginTime.value = document.forms[0].beginTime.value;
	document.forms['excelForm'].endTime.value = document.forms[0].endTime.value;
	document.forms['excelForm'].submit();
}
function tradePicStatSubmit() {
	var elem = document.forms[0].statType;
	var value = elem.value;
	if (value == '-1') {
		show("statTypeNotEmpty");
		elem.focus();
		return false;
	}
	if (document.getElementById("timeByHand").checked) {
		var beginTime1Value = document.getElementById("beginTime1").value;
		var endTime1Value = document.getElementById("endTime1").value;
		if (beginTime1Value && !endTime1Value) {
			show("endTime1NotEmpty");
			return false;
		} else if (endTime1Value && !beginTime1Value) {
			show("beginTime1NotEmpty");
			return false;
		}
		
		var beginTime2Value = document.getElementById("beginTime2").value;
		var endTime2Value = document.getElementById("endTime2").value;
		if (beginTime2Value && !endTime2Value) {
			show("endTime2NotEmpty");
			return false;
		} else if (endTime2Value && !beginTime2Value) {
			show("beginTime2NotEmpty");
			return false;
		}
		
		var beginTime3Value = document.getElementById("beginTime3").value;
		var endTime3Value = document.getElementById("endTime3").value;
		if (beginTime3Value && !endTime3Value) {
			show("endTime3NotEmpty");
			return false;
		} else if (endTime3Value && !beginTime3Value) {
			show("beginTime3NotEmpty");
			return false;
		}
		
		var beginTime4Value = document.getElementById("beginTime4").value;
		var endTime4Value = document.getElementById("endTime4").value;
		if (beginTime4Value && !endTime4Value) {
			show("endTime4NotEmpty");
			return false;
		} else if (endTime4Value && !beginTime4Value) {
			show("beginTime4NotEmpty");
			return false;
		}
	}
	return true;
}
function dealStatTypePrompt() {
	var elem = document.forms[0].statType;
	var value = elem.value;
	if (value != "-1")
		hide("statTypeNotEmpty");
}
function performanceNoReplySort(sort, sortOrder) {
	document.forms[0].noReplySort.value = sort;
	document.forms[0].noReplySortOrder.value = sortOrder;
	document.forms[0].submit();
}
function performanceAvgSort(sort, sortOrder) {
	document.forms[0].avgSort.value = sort;
	document.forms[0].avgSortOrder.value = sortOrder;
	document.forms[0].submit();
}
function dealCreatedPrompt() {
	var avgTypeElem = document.forms[0].avgType;
	var value = avgTypeElem.value;
	value = trimString(value);
	var elem = null;
	if (value == "0")
		elem = document.forms[0].dayTime;
	else if (value == "1")
		elem = document.forms[0].weekTime;
	else
		elem = document.forms[0].monthTime;

	var tmpValue = elem.value;
	tmpValue = trimString(tmpValue);
	if (tmpValue != "")
		hide("createdNotEmpty");
	if (value == "1")
		dealWeekBeginPrompt();
}
function changeAvgTime() {
	var avgTypeElem = document.forms[0].avgType;
	var value = avgTypeElem.value;
	value = trimString(value);
	if (value == "0") {
		show("daySpan");
		hide("weekSpan");
		hide("monthSpan");
	} else if (value == "1") {
		hide("daySpan");
		show("weekSpan");
		hide("monthSpan");
	} else {
		hide("daySpan");
		hide("weekSpan");
		show("monthSpan");
	}
	dealCreatedPrompt();
}
function changePerformanceType() {
	var typeElem = document.forms[0].type;
	var value = typeElem.value;
	value = trimString(value);
	if (value == "0" || value == "1") {
		show("replyTr");
		hide("avgTr");
	} else if (value == "2") {
		hide("replyTr");
		show("avgTr");
	}
}
function newOldCustomerStat() {
//	var elem = document.forms[0].type;
//	var value = elem.value;
//	value = trimString(value);
//	if (value == "1") {
		var newOldCustomerTypeElem = document.forms[0].newOldCustomerType;
		var newOldCustomerTypeValue = newOldCustomerTypeElem.value;
		newOldCustomerTypeValue = trimString(newOldCustomerTypeValue);
		var elem = null;
		if (newOldCustomerTypeValue == "3")
			elem = document.forms[0].dayTime;
		else if (newOldCustomerTypeValue == "2")
			elem = document.forms[0].weekTime;
		else
			elem = document.forms[0].monthTime;
	
		var value = elem.value;
		if (!value) {
			show("createdNotEmpty");
			elem.focus();
			if (newOldCustomerTypeValue != "1")
			elem.select();
			return false;
		}
	
		if (newOldCustomerTypeValue == "2") {
			var weekElem = document.forms[0].weekTime;
			var dict = isWeekBeginDict();
			if (!dict.isWeekBegin) {
				weekElem.focus();
				weekElem.select();
				return false;
			}
		}
//	}
	return true;
}
function newOldCustomerSubmitCheck() {
	var newOldCustomerTypeElem = document.forms[0].newOldCustomerType;
	var newOldCustomerTypeValue = newOldCustomerTypeElem.value;
	newOldCustomerTypeValue = trimString(newOldCustomerTypeValue);
	var elem = null;
	if (newOldCustomerTypeValue == "3")
		elem = document.forms[0].dayTime;
	else if (newOldCustomerTypeValue == "2")
		elem = document.forms[0].weekTime;
	else
		elem = document.forms[0].monthTime;

	var value = elem.value;
	if (!value) {
		show("createdNotEmpty");
		elem.focus();
		if (newOldCustomerTypeValue != "1")
		elem.select();
		return false;
	}

	if (newOldCustomerTypeValue == "2") {
		var weekElem = document.forms[0].weekTime;
		var dict = isWeekBeginDict();
		if (!dict.isWeekBegin) {
			weekElem.focus();
			weekElem.select();
			return false;
		}
	}
	return true;
}
function dealNewOldCustomerPrompt() {
	var newOldCustomerTypeElem = document.forms[0].newOldCustomerType;
	var value = newOldCustomerTypeElem.value;
	value = trimString(value);
	var elem = null;
	if (value == "3")
		elem = document.forms[0].dayTime;
	else if (value == "2")
		elem = document.forms[0].weekTime;
	else
		elem = document.forms[0].monthTime;

	var tmpValue = elem.value;
	tmpValue = trimString(tmpValue);
	if (tmpValue != "")
		hide("createdNotEmpty");
	if (value == "2")
		dealWeekBeginPrompt();
}
function changeNewOldCustomerTime() {
	var newOldCustomerTypeElem = document.forms[0].newOldCustomerType;
	var value = newOldCustomerTypeElem.value;
	value = trimString(value);
	if (value == "3") {
		show("daySpan");
		hide("weekSpan");
		hide("monthSpan");
	} else if (value == "2") {
		hide("daySpan");
		show("weekSpan");
		hide("monthSpan");
	} else {
		hide("daySpan");
		hide("weekSpan");
		show("monthSpan");
	}
	dealNewOldCustomerPrompt();
}
function changeCustomerType() {
	var typeElem = document.forms[0].type;
	var value = typeElem.value;
	value = trimString(value);
	
	var customerType0 = document.getElementById('customerType0');
	var customerType1 = document.getElementById('customerType1');
	
	if (value == "0") {
	    show("integrationLevelTr");
	    hide("newOldCustomerTr");
		if (customerType0)
			show('customerType0');
		if (customerType1)
			hide('customerType1');
	} else if (value == "1") {
	    hide("integrationLevelTr");
	    show("newOldCustomerTr");
	    if (customerType0)
			hide('customerType0');
		if (customerType1)
			show('customerType1');
	}
}
function changeCustomerStatType() {
	var typeElem = document.forms[0].type;
	var value = typeElem.value;
	value = trimString(value);

	var customerStatType0 = document.getElementById('customerStatType0');
	var customerStatType1 = document.getElementById('customerStatType1');
	
	if (value == "0") {
	    hide("newOldCustomerTr");
		if (customerStatType0)
			show('customerStatType0');
		if (customerStatType1)
			hide('customerStatType1');
	} else if (value == "1") {
	    show("newOldCustomerTr");
	    if (customerStatType0)
			hide('customerStatType0');
		if (customerStatType1)
			show('customerStatType1');
	}
}
function isWeekBeginDict() {
	var value = document.forms[0].weekTime.value;
	if (value) {
		var li = value.split("-");
		var year = parseInt(li[0]);
		var month = parseInt(li[1].replace(/^0/, '')) - 1;
		var date = parseInt(li[2].replace(/^0/, ''));
	
		var specDate = new Date(year, month, date);
	
		var flag = specDate.getDay() == 1;
	
		var weekEndDate = new Date(year, month, date);
		weekEndDate.setDate(weekEndDate.getDate() + 6);
	
		return {
			"isEmpty": false,
			"isWeekBegin": flag,
			"weekEnd": getYMD(weekEndDate)
		};
	}
	return {
		"isEmpty": true
	};
}
function dealWeekBeginPrompt() {
	var weekJudgeDict = isWeekBeginDict();
	if (weekJudgeDict["isEmpty"])
		hide("weekTimeEnd");
	else {
		if (weekJudgeDict["isWeekBegin"]) {
			document.getElementById("weekTimeEnd").innerHTML = "~" + weekJudgeDict["weekEnd"];
		} else {
			document.getElementById("weekTimeEnd").innerHTML = "非周开始时间";
		}
		show("weekTimeEnd");
	}
}
function performanceStat() {
	var elem = document.forms[0].type;
	var value = elem.value;
	value = trimString(value);
	if (value == "2") {
		var avgTypeElem = document.forms[0].avgType;
		var avgTypeValue = avgTypeElem.value;
		avgTypeValue = trimString(avgTypeValue);
		var elem = null;
		if (avgTypeValue == "0")
			elem = document.forms[0].dayTime;
		else if (avgTypeValue == "1")
			elem = document.forms[0].weekTime;
		else
			elem = document.forms[0].monthTime;
	
		var value = elem.value;
		if (!value) {
			show("createdNotEmpty");
			elem.focus();
			if (avgTypeValue != "2")
			elem.select();
			return false;
		}
	
		if (avgTypeValue == "1") {
			var weekElem = document.forms[0].weekTime;
			var dict = isWeekBeginDict();
			if (!dict.isWeekBegin) {
				weekElem.focus();
				weekElem.select();
				return false;
			}
		}
	}
	return true;
}
function performanceStatExcelSubmit() {
	document.forms["excelForm"].type.value = document.forms[0].type.value;
	document.forms["excelForm"].userId.value = document.forms[0].userId.value;
	document.forms["excelForm"].roleId.value = document.forms[0].roleId.value;
	document.forms["excelForm"].beginTime.value = document.forms[0].beginTime.value;
	document.forms["excelForm"].endTime.value = document.forms[0].endTime.value;
	document.forms["excelForm"].noReplySort.value = document.forms[0].noReplySort.value;
	document.forms["excelForm"].noReplySortOrder.value = document.forms[0].noReplySortOrder.value;
	document.forms["excelForm"].avgSort.value = document.forms[0].avgSort.value;
	document.forms["excelForm"].avgSortOrder.value = document.forms[0].avgSortOrder.value;
	document.forms["excelForm"].avgType.value = document.forms[0].avgType.value;
	document.forms["excelForm"].dayTime.value = document.forms[0].dayTime.value;
	document.forms["excelForm"].weekTime.value = document.forms[0].weekTime.value;
	document.forms["excelForm"].monthTime.value = document.forms[0].monthTime.value;
	document.forms['excelForm'].submit();    
}
function performancePicStatSubmit() {
	var elem = document.forms[0].type;
	var value = elem.value;
	if (value == '-1') {
		show("typeNotEmpty");
		elem.focus();
		return false;
	} else if (value == "1") {
		var evaluationNameElem = document.forms[0].evaluationName;
		var evaluationNameValue = evaluationNameElem.value;
		if (!evaluationNameElem.value) {
			show("evaluationNameNotEmpty");
			evaluationNameElem.focus();
			return false;
		}
	}
	if (value != "2") {
		if (document.getElementById("timeByHand").checked) {
			var beginTime1Value = document.getElementById("beginTime1").value;
			var endTime1Value = document.getElementById("endTime1").value;
			if (beginTime1Value && !endTime1Value) {
				show("endTime1NotEmpty");
				return false;
			} else if (endTime1Value && !beginTime1Value) {
				show("beginTime1NotEmpty");
				return false;
			}
			
			var beginTime2Value = document.getElementById("beginTime2").value;
			var endTime2Value = document.getElementById("endTime2").value;
			if (beginTime2Value && !endTime2Value) {
				show("endTime2NotEmpty");
				return false;
			} else if (endTime2Value && !beginTime2Value) {
				show("beginTime2NotEmpty");
				return false;
			}
			
			var beginTime3Value = document.getElementById("beginTime3").value;
			var endTime3Value = document.getElementById("endTime3").value;
			if (beginTime3Value && !endTime3Value) {
				show("endTime3NotEmpty");
				return false;
			} else if (endTime3Value && !beginTime3Value) {
				show("beginTime3NotEmpty");
				return false;
			}
			
			var beginTime4Value = document.getElementById("beginTime4").value;
			var endTime4Value = document.getElementById("endTime4").value;
			if (beginTime4Value && !endTime4Value) {
				show("endTime4NotEmpty");
				return false;
			} else if (endTime4Value && !beginTime4Value) {
				show("beginTime4NotEmpty");
				return false;
			}
		}
	} else {
		if (document.getElementById("avgWaitTimeByHand").checked) {
			var avgType = document.forms[0].avgType;
			var avgTypeValue;
			for (var i = 0; i < avgType.length; i++)
				if (avgType[i].checked)
					avgTypeValue = avgType[i].value;
	
			if (avgTypeValue == "1") {
				var elem = document.forms[0].avgWaitWeekTime1;
				var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
				if (!weekJudgeDict['isEmpty'] && !weekJudgeDict["isWeekBegin"]) {
					elem.focus();
					elem.select();
					return false;
				}
		
				var elem = document.forms[0].avgWaitWeekTime2;
				var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
				if (!weekJudgeDict['isEmpty'] && !weekJudgeDict["isWeekBegin"]) {
					elem.focus();
					elem.select();
					return false;
				}
		
				var elem = document.forms[0].avgWaitWeekTime3;
				var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
				if (!weekJudgeDict['isEmpty'] && !weekJudgeDict["isWeekBegin"]) {
					elem.focus();
					elem.select();
					return false;
				}
		
				var elem = document.forms[0].avgWaitWeekTime4;
				var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
				if (!weekJudgeDict['isEmpty'] && !weekJudgeDict["isWeekBegin"]) {
					elem.focus();
					elem.select();
					return false;
				}
			}
		}
	}
	return true;
}
function dealTypePrompt() {
	var elem = document.forms[0].type;
	var value = elem.value;
	if (value != "-1")
		hide("typeNotEmpty");
}
function changePerformancePicStatType() {
	var elem = document.forms[0].type;
	var value = elem.value;
	if (value == "-1") {
		show("fieldSelect");
		hide("noReplyNumField");
		hide("evaluationNameField");
		hide("avgWaitTimeField");
	
		show("noReplyEvaluationSection");
		hide("avgWaitTimeSection");
		picStatShowHideTimeByHand();
		showHideAvgWaitTimeByHand();
		return;
	}
	if (value == "0") {
		hide("fieldSelect");
		show("noReplyNumField");
		hide("evaluationNameField");
		hide("avgWaitTimeField");
	
		show("noReplyEvaluationSection");
		hide("avgWaitTimeSection");
		picStatShowHideTimeByHand();
		showHideAvgWaitTimeByHand();
		return;
	}
	if (value == "1") {
		hide("fieldSelect");
		hide("noReplyNumField");
		show("evaluationNameField");
		hide("avgWaitTimeField");
	
		show("noReplyEvaluationSection");
		hide("avgWaitTimeSection");
		picStatShowHideTimeByHand();
		showHideAvgWaitTimeByHand();
		return;
	}
	if (value == "2") {
		hide("fieldSelect");
		hide("noReplyNumField");
		hide("evaluationNameField");
		show("avgWaitTimeField");
	
		hide("noReplyEvaluationSection");
		show("avgWaitTimeSection");
		picStatShowHideTimeByHand();
		showHideAvgWaitTimeByHand();
		return;
	}
	return;
}
function dealEvaluationNamePrompt() {
	var elem = document.forms[0].evaluationName;
	if (elem.value)
		hide("evaluationNameNotEmpty");
}
function showHideAvgWaitTimeByHand() {
	var elem = document.forms[0].type;
	var value = elem.value;
	if (value == "2") {
		if (document.getElementById("avgWaitTimeByHand").checked) {
			show("avgWaitTimeByHandTBody");
			document.getElementById("avgWaitTimeArea").disabled = true;
		}
		else {
			document.getElementById("avgWaitTimeArea").disabled = false;
			hide("avgWaitTimeByHandTBody");
		}
	} else 
		hide("avgWaitTimeByHandTBody");
}
function picStatShowHideTimeByHand() {
	var elem = document.forms[0].type;
	var value = elem.value;
	if (value != "2") {
		if (document.getElementById("timeByHand").checked) {
			show("timeByHandTBody");
			document.getElementById("timeArea").disabled = true;
		}
		else {
			document.getElementById("timeArea").disabled = false;
			hide("timeByHandTBody");
		}
	} else
		hide("timeByHandTBody");
}
function showHideAvgTypeSub() {
	var avgType = document.forms[0].avgType;
	var avgTypeValue;
	for (var i = 0; i < avgType.length; i++)
	if (avgType[i].checked)
		avgTypeValue = avgType[i].value;

	if (avgTypeValue == "0") {
		showAvgTypeDayGroup();
		hideAvgTypeWeekGroup();
		hideAvgTypeMonthGroup();
	} else if (avgTypeValue == "1") {
		hideAvgTypeDayGroup();
		showAvgTypeWeekGroup();
		hideAvgTypeMonthGroup();
	} else if (avgTypeValue == "2") {
		hideAvgTypeDayGroup();
		hideAvgTypeWeekGroup();
		showAvgTypeMonthGroup();
	}
}
function showAvgTypeDayGroup() {
	show("avgWaitBeginTime1Tr");
	show("avgWaitBeginTime2Tr");
	show("avgWaitBeginTime3Tr");
	show("avgWaitBeginTime4Tr");
}
function hideAvgTypeDayGroup() {
	hide("avgWaitBeginTime1Tr");
	hide("avgWaitBeginTime2Tr");
	hide("avgWaitBeginTime3Tr");
	hide("avgWaitBeginTime4Tr");
}
function showAvgTypeWeekGroup() {
	show("avgWaitWeekTime1Tr");
	show("avgWaitWeekTime2Tr");
	show("avgWaitWeekTime3Tr");
	show("avgWaitWeekTime4Tr");
}
function hideAvgTypeWeekGroup() {
	hide("avgWaitWeekTime1Tr");
	hide("avgWaitWeekTime2Tr");
	hide("avgWaitWeekTime3Tr");
	hide("avgWaitWeekTime4Tr");
}
function showAvgTypeMonthGroup() {
	show("avgWaitMonthTime1Tr");
	show("avgWaitMonthTime2Tr");
	show("avgWaitMonthTime3Tr");
	show("avgWaitMonthTime4Tr");
}
function hideAvgTypeMonthGroup() {
	hide("avgWaitMonthTime1Tr");
	hide("avgWaitMonthTime2Tr");
	hide("avgWaitMonthTime3Tr");
	hide("avgWaitMonthTime4Tr");
}
function isAvgWaitWeekBeginDict(avgWaitWeekTime) {
	var value = avgWaitWeekTime.value;
	if (value) {
		var li = value.split("-");
		var year = parseInt(li[0]);
		var month = parseInt(li[1].replace(/^0/, '')) - 1;
		var date = parseInt(li[2].replace(/^0/, ''));
	
		var specDate = new Date(year, month, date);
	
		var flag = specDate.getDay() == 0;
	
		var weekEndDate = new Date(year, month, date);
		weekEndDate.setDate(weekEndDate.getDate() + 6);
	
		return {
			"isEmpty": false,
			"isWeekBegin": flag,
			"weekEnd": getYMD(weekEndDate)
		};
	}
	return {
		"isEmpty": true
	};
}
function dealAvgWaitWeekTime1Prompt() {
	var elem = document.forms[0].avgWaitWeekTime1;
	var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
	if (weekJudgeDict["isEmpty"])
		hide("avgWaitWeekTime1End");
	else {
		if (weekJudgeDict["isWeekBegin"]) {
			document.getElementById("avgWaitWeekTime1End").innerHTML = "~" + weekJudgeDict["weekEnd"];
		} else {
			document.getElementById("avgWaitWeekTime1End").innerHTML = "非周开始时间";
		}
		show("avgWaitWeekTime1End");
	}
}
function dealAvgWaitWeekTime2Prompt() {
	var elem = document.forms[0].avgWaitWeekTime2;
	var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
	if (weekJudgeDict["isEmpty"])
		hide("avgWaitWeekTime2End");
	else {
		if (weekJudgeDict["isWeekBegin"]) {
			document.getElementById("avgWaitWeekTime2End").innerHTML = "~" + weekJudgeDict["weekEnd"];
		} else {
			document.getElementById("avgWaitWeekTime2End").innerHTML = "非周开始时间";
		}
		show("avgWaitWeekTime2End");
	}
}
function dealAvgWaitWeekTime3Prompt() {
	var elem = document.forms[0].avgWaitWeekTime3;
	var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
	if (weekJudgeDict["isEmpty"])
		hide("avgWaitWeekTime3End");
	else {
		if (weekJudgeDict["isWeekBegin"]) {
			document.getElementById("avgWaitWeekTime3End").innerHTML = "~" + weekJudgeDict["weekEnd"];
		} else {
			document.getElementById("avgWaitWeekTime3End").innerHTML = "非周开始时间";
		}
		show("avgWaitWeekTime3End");
	}
}
function dealAvgWaitWeekTime4Prompt() {
	var elem = document.forms[0].avgWaitWeekTime4;
	var weekJudgeDict = isAvgWaitWeekBeginDict(elem);
	if (weekJudgeDict["isEmpty"])
		hide("avgWaitWeekTime4End");
	else {
		if (weekJudgeDict["isWeekBegin"]) {
			document.getElementById("avgWaitWeekTime4End").innerHTML = "~" + weekJudgeDict["weekEnd"];
		} else {
			document.getElementById("avgWaitWeekTime4End").innerHTML = "非周开始时间";
		}
		show("avgWaitWeekTime4End");
	}
}
function dealChatAnswerContentPrompt() {
	var elem = document.forms[0].chatAnswerContent;
	var origValue = elem.value;
	value = trimString(origValue);
	if (!value == "")
		hide("chatAnswerContentNotEmpty");
	if (origValue.length <= 500)
		hide("chatAnswerContentLengthNotValid");
}
function chatAnswerSearch() {
	var elem = document.forms[0].chatAnswerContent;
	var origValue = elem.value;
	value = trimString(origValue);
	if (value == "") {
		show("chatAnswerContentNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (origValue.length > 500) {
		show("chatAnswerContentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function chatMouseOverStyle(elem) {
	if (elem.className != "chatMsgMouseOver")
		elem.className = "chatMsgMouseOver";
}
function chatMouseOutStyle(elem) {
	if (document.getElementById(elem.id + "_content").style.display == "none")
		elem.className = "chatMsgMouseOut";
}
/**
   dialogId is number
 */
/*
function initDialog(dialogId) {
	$("#dialog" + dialogId).dialog({
		autoOpen: false,
		width: 650
		});
}
*/
/**
  dialogId is number
 */
function showChatMsgHelper(elem, dialogId) {
	if (document.getElementById(elem.id + "_content").style.display == "none") {
		var divLi = document.getElementById("chatpeer_" + dialogId + "Child").getElementsByTagName("div");
		for (var i = 0; i < divLi.length; i++) {
			if (divLi[i].className == "dialogDown" && divLi[i].style.display == "") {
				divLi[i].style.display = "none";
				break;
			}
		}
		document.getElementById(elem.id + "_content").style.display = "";
		var liLi = document.getElementById("dialogUp" + dialogId).getElementsByTagName("li");
		for (var i = 0; i < liLi.length; i++) {
			chatMouseOutStyle(liLi[i]);
		}
	}
}
/**
  dialogId is number
 */
function openChatDialog(dialogId) {
	if (!$("#dialog" + dialogId).dialog("isOpen")) {
		$("#dialog" + dialogId).dialog("open");
	}
	document.getElementById("dialogUp" + dialogId).scrollTop = document.getElementById("dialogUp" + dialogId).scrollHeight;
	$("#dialog" + dialogId).animate({backgroundColor: "black"}, 1000);
	$("#dialog" + dialogId).animate({backgroundColor: "#EEEEEE"}, 1000);
	$("#dialog" + dialogId).dialog("moveToTop");
}
/**
  dialogId is number
 */
function newChatMsgTimeout(dialogId) {
	return function() {
		newChatMsg(dialogId);
	}
}
/**
  dialogId is number
 */
function newChatMsg(dialogId) {
	var dialogElem = document.getElementById("dialogUp" + dialogId);
	dialogElem.scrollTop = dialogElem.scrollHeight;
	var dialogUpUl = dialogElem.getElementsByTagName("ul")[0];
	var lastDialogUpLi = dialogUpUl.getElementsByTagName("li")[dialogUpUl.getElementsByTagName("li").length - 1];
	lastDialogUpLi.onclick();
	
	if (!$("#dialog" + dialogId).dialog("isOpen")) {
		$("#dialog" + dialogId).dialog("open");
	}
	$("#dialog" + dialogId).animate({backgroundColor: "black"}, 1000);
	$("#dialog" + dialogId).animate({backgroundColor: "#EEEEEE"}, 1000);
	$("#dialog" + dialogId).dialog("moveToTop");
}
function getDialogs() {
	var divLi = document.getElementsByTagName("div");
	var result = [];
	for (var i = 0; i < divLi.length; i++) {
		if (/^dialog\d+$/g.test(divLi[i].id)) {
			result.push(divLi[i]);
	}
	}
	return result;
}
/**
  dialogId is number
 */
function createDialog(dialogId, uid) {
	var dialogDivElem = document.createElement("div");
	dialogDivElem.id = "chatpeer_" + dialogId + "Child";
	dialogDivElem.title = uid;
	dialogDivElem.style.display = "none";

	var array = [];
	array.push('<p class="content2">消息</p>');
	array.push('<div id="dialogUpDIALOG_ID" class="dialogUp">'.replace('DIALOG_ID', dialogId));
	array.push('<ul>');
	array.push('</ul>');
	array.push('</div>');
	array.push('<p class="content2">回复</p>');

	dialogDivElem.innerHTML = array.join('');

	return dialogDivElem;
}
function chatMsgClickFunc(liElem, counter1) {
	return function() {
	showChatMsgHelper(liElem, counter1);
	}
}

/**
   dialogId is string, eg:dialog0
   dataItem is data return from server
 */
function createDialogMsgAndContent(dialogElem, dataItem) {
	var dialogId = dialogElem.id;
	// add new content, append, and chatHelper relate msg
	var dialogUpUl = dialogElem.getElementsByTagName("ul")[0];
	var counter1 = parseInt(dialogId.match(/^chatpeer_(\d+)Child$/)[1]);
	var counter2 = dialogUpUl.getElementsByTagName("li").length;
	for (var k = 0; k < dataItem.msgs.length; k++) {
		// create li
		var liElem = document.createElement("li");
		liElem.id = "UID_VALUE_message_PARENT_COUNTER_SELF_COUNTER";
		liElem.id = liElem.id.replace('UID_VALUE', dataItem.uid);
		liElem.id = liElem.id.replace('PARENT_COUNTER', counter1);
		liElem.id = liElem.id.replace('SELF_COUNTER', counter2);
		
		/*{{msgItem.time}}<br />{{msgItem.content}}*/
		var liHtml = "MSG_ITEM_TIME<br />MSG_ITEM_CONTENT";
		liHtml = liHtml.replace("MSG_ITEM_TIME", dataItem.msgs[k].time);
		liHtml = liHtml.replace("MSG_ITEM_CONTENT", dataItem.msgs[k].content);
		liElem.innerHTML = liHtml;
		
		dialogUpUl.appendChild(liElem);
	
		// create content
		var contentDivElem = document.createElement("div");
		contentDivElem.className = "dialogDown";
		contentDivElem.style.display = "none";
		contentDivElem.id = liElem.id + "Child";

		var contentUlElem = document.createElement("ul");
		for (var l = 0; l < dataItem.msgs[k].chatHelper.length; l++) {
			var contentLiElem = document.createElement("li");
			
			var contentLiHtmlArray = [];
			contentLiHtmlArray.push('<table cellSpacing="0" cellPadding="0"  border="0">');
			contentLiHtmlArray.push('<tr>');
			contentLiHtmlArray.push('<td class="width100">');
			contentLiHtmlArray.push("CHAT_HELPER_ITEM_NICK&nbsp;CHAT_HELPER_ITEM_TIME<br />");
			var chatContentId = liElem.id + '_' + l + '_chatContent';
			contentLiHtmlArray.push("<span id='SPAN_ID'>CHAT_HELPER_ITEM_CONTENT</span>".replace('SPAN_ID', chatContentId));
			contentLiHtmlArray.push('</td>');
			contentLiHtmlArray.push('<td>');
			contentLiHtmlArray.push("<input type='button' class='bn_2 floatRight' value='复制' onclick='CLICK_FUNC' />".replace('CLICK_FUNC', 'copyToClipboard(document.getElementById("SPAN_ID").innerHTML)'.replace('SPAN_ID', chatContentId)));
			contentLiHtmlArray.push('</td>');
			contentLiHtmlArray.push('</tr>');
			contentLiHtmlArray.push('</table>');
			var contentLiHtml = contentLiHtmlArray.join("");
			contentLiHtml = contentLiHtml.replace("CHAT_HELPER_ITEM_NICK", dataItem.msgs[k].chatHelper[l].nick);
			contentLiHtml = contentLiHtml.replace("CHAT_HELPER_ITEM_TIME", dataItem.msgs[k].chatHelper[l].time);
			contentLiHtml = contentLiHtml.replace("CHAT_HELPER_ITEM_CONTENT", dataItem.msgs[k].chatHelper[l].content);
	
			contentLiElem.innerHTML = contentLiHtml;
			contentUlElem.appendChild(contentLiElem);
		}
		contentDivElem.appendChild(contentUlElem);
		dialogElem.appendChild(contentDivElem);

		// add or create menu event
		var dialogItem = dialogConfig.findDialogItem(dialogElem);
		if (dialogItem) {
			var liMenuObj = dialogConfig.findDialogMenu(dialogItem);
			if (liMenuObj)
				addMenu(liMenuObj, liElem.id);
		}
		
		counter2++;
	}
	
	// click last item
	var liLength = dialogUpUl.getElementsByTagName("li").length;
	if (liLength > 0) {
		// to fix in firefox
		var liLastElem = dialogUpUl.getElementsByTagName("li")[liLength - 1];
		if (liLastElem.onclick) {
			liLastElem.onclick();
		}
	}
	
	var dialogUpElem = document.getElementById('dialogUp' + counter1);
	dialogUpElem.scrollTop = dialogUpElem.scrollHeight;
	
	var counter2 = dialogUpUl.getElementsByTagName("li").length;
	// popup dialog, scroll to last li elem TODO, and click, if not current node, newMsg,
	if (dataItem.msgs.length > 0) {
		var currentElemId = "chatpeer_" + counter1;
		if (dialogConfig.chatpeerMenu) {
			if (dialogConfig.chatpeerMenu.decorator.menuMediator.currentNode.elem.id != currentElemId) {
				var currentElem = document.getElementById(currentElemId);
				if (currentElem.className)
					currentElem.className += " newmsg";
				else
					currentElem.className = "newmsg";
			}
		} else {
			var currentElem = document.getElementById(currentElemId);
			if (currentElem.className)
				currentElem.className += " newmsg";
			else
				currentElem.className = "newmsg";
		}
	}
}

/**
   dialogId is number, eg:0
 */
function openChatDialogFunc(dialogId) {
	return function() {
	openChatDialog(dialogId);
	}
}
/**
   dialogId is number, eg:0
 */
function createChatLi(dialogId, uid) {
	var liElem = document.createElement("li");
	var liHtmlArray = [];
	liHtmlArray.push("<a id='chatpeer_COUNTER' href='javascript:void(0)' title='UID'>");
	liHtmlArray.push("UID");
	liHtmlArray.push("</a>");
	var liHtml = liHtmlArray.join("");
	liHtml = liHtml.replace("COUNTER", dialogId);
	liHtml = liHtml.replace(/UID/g, uid);
	liElem.innerHTML = liHtml;
	
	return liElem;
}

/**
	simple menu, in the same page, click one menu, hide the other
*/
function addMenu(menuObj, id) {
	var menuItem = menuObj.factory.addTreeNode(id);
	menuObj.decorator.addSingleMenuEvent(menuItem);
}

function createMenu(obj, cls1, cls2, cls3, isReverse) {
	var factory = new SimpleMenuFactory(obj, cls1, cls2, cls3);
	var decorator = new SimpleMenuEventDecorator();
	decorator.addSimpleMenuEvent(factory.build(), isReverse);
	return {
		factory : factory,
		decorator : decorator
	}
}

function show(id) {
	document.getElementById(id).style.display = "";
}

function hide(id) {
	document.getElementById(id).style.display = "none";
}

function toggle(id) {
	if (!isShow(id))
		show(id);
	else
		hide(id);
}

function isShow(id) {
	return document.getElementById(id).style.display == "";
}

/**
 * 菜单节点
 */
function SimpleMenu(elem, mouseOutCls, mouseOverCls, mouseClickCls) {
	this.elem = elem;
	this.mouseOutCls = mouseOutCls;
	this.mouseOverCls = mouseOverCls;
	this.mouseClickCls = mouseClickCls;
	this.clickExtendFunc = [];
}

SimpleMenu.prototype.mouseOut = function() {
	this._changeCls(this.mouseOverCls, this.mouseClickCls, this.mouseOutCls);
}

SimpleMenu.prototype.mouseOver = function() {
	this._changeCls(this.mouseOutCls, this.mouseClickCls, this.mouseOverCls);
}

SimpleMenu.prototype.mouseClick = function() {
	this._changeCls(this.mouseOutCls, this.mouseOverCls, this.mouseClickCls);
	this._clearNewCls();
	if (this.childElem && !isShow(this.childElem.id)) {
		show(this.childElem.id);
		for (var i = 0; i < this.clickExtendFunc.length; i++)
			this.clickExtendFunc[i](this.childElem.id);
	}
}

function scrollMenu(dialogElemId) {
	var dialogId = dialogElemId.match(/^chatpeer_(\d+)Child$/)[1];
	var dialogUpElem = document.getElementById("dialogUp" + dialogId);
	dialogUpElem.scrollTop = dialogUpElem.scrollHeight;
}

SimpleMenu.prototype.hideChild = function() {
	if (this.childElem && isShow(this.childElem.id))
		hide(this.childElem.id);
}

SimpleMenu.prototype._changeCls = function(cls1, cls2, cls3) {
	var className = this.elem.className;
	className = className.replace(cls1, "");
	className = className.replace(cls2, "");
	className = className.replace(cls3, "");
	if (className == "")
		className += cls3;
	else
		className += " " + cls3;
	className = className.replace(/\s{2,}/g, " ");
	this.elem.className = className;
}

SimpleMenu.prototype._clearNewCls = function() {
	var className = this.elem.className;
	if (className.indexOf('newmsg') > -1) {
		className = className.replace('newmsg', '');
		className = className.replace(/\s{2,}/g, " ");
		this.elem.className = className;
	}
}

/**
 * 根据id和相应的样式而建立一个菜单树
 */
function SimpleMenuFactory(baseConfig) {
	// this.baseConfig = {
	// id : "Menu_01",
	// cls1 : ["black2px", "blue2px", "red2px"],
	// cls2 : ["black2px", "blue2px", "red2px"],
	// cls3 : ["black2px", "blue2px", "red2px"]
	// };
	if (typeof baseConfig == "string") {
		this.baseConfig = {
			id : baseConfig,
			cls1 : [ arguments[1], arguments[2], arguments[3] ]
		};
	} else
		this.baseConfig = baseConfig;
	this.simpleConfig = {
		childs : []
	};
}

SimpleMenuFactory.prototype.build = function() {
	this._buildTree(this.simpleConfig, this.baseConfig.id);
	return this.simpleConfig.childs;
}

SimpleMenuFactory.prototype.addTreeNode = function(elemId) {
	var elem = document.getElementById(elemId);
	if (elem) {
		var array = elemId.match(/(_\d+)$/);
		if (array) {
			var clsArray = this.baseConfig["cls1"];
			var menu = new SimpleMenu(elem, clsArray[0], clsArray[1], clsArray[2]);
			var childElem = document.getElementById(elemId + "Child");
			if (childElem)
				menu.childElem = childElem;
			this.simpleConfig.childs.push(menu);
			return menu;
		}
	}
	return null;
}

SimpleMenuFactory.prototype._buildTree = function(simpleParent, elemId) {
	var baseConfig = this.baseConfig;
	var elem = document.getElementById(elemId);
	if (elem) {
		var array = elemId.match(/(_\d+)$/);
		if (array) {
			var clsArray = baseConfig["cls1"];
			var menu = new SimpleMenu(elem, clsArray[0], clsArray[1], clsArray[2]);
			var childElem = document.getElementById(elemId + "Child");
			if (childElem)
				menu.childElem = childElem;
			simpleParent.childs.push(menu);

			var nextElemId = this._getIncrementElemeId(elemId);
			this._buildTree(simpleParent, nextElemId);
		} else
			alert("the regulation of name is wrong,id=" + elemId);
	}
}

SimpleMenuFactory.prototype._getIncrementElemeId = function(id) {
	return treeNextElemIdGenerator(id);
}

SimpleMenuFactory.prototype.pushClickFunc = function() {
	for(var i = 0; i < this.simpleConfig.childs.length; i++) {
		var j = 0;
		for (; j < this.simpleConfig.childs[i].clickExtendFunc.length; j++) {
			if (this.simpleConfig.childs[i].clickExtendFunc[j] == scrollMenu)
				break;
		}
		if (j >= this.simpleConfig.childs[i].clickExtendFunc.length)
			this.simpleConfig.childs[i].clickExtendFunc.push(scrollMenu);
	}
}

function treeNextElemIdGenerator(id) {
	var regexp = /_\d+$/;
	var array = id.match(regexp);
	var num = parseInt(array[0].substring(1)) + 1;
	return id.replace(regexp, "_" + num);
}

/**
 * 这时,已知每个menu都可以触发三种事件,mClick,mOut,mOver,
 *
 * 要在这里完成单击某个节点时,进行和其余的节点的交互
 */
function SimpleMenuMediator() {
	this.currentNode = null;
}

SimpleMenuMediator.prototype.mouseOut = function(simpleMenu) {
	if (simpleMenu != this.currentNode)
		simpleMenu.mouseOut();
}

SimpleMenuMediator.prototype.mouseOver = function(simpleMenu) {
	if (simpleMenu != this.currentNode)
		simpleMenu.mouseOver();
}

SimpleMenuMediator.prototype.mouseClick = function(simpleMenu) {
	if (simpleMenu != this.currentNode) {
		this.currentNode.mouseOut();
		this.currentNode.hideChild();
		this.currentNode = simpleMenu;
	}
	this.currentNode.mouseClick();
}

function SimpleMenuEventDecorator() {
	this.menuMediator = new SimpleMenuMediator();
}

SimpleMenuEventDecorator.prototype.addSimpleMenuEvent = function(configArray, isReverse) {
	for ( var i = 0; i < configArray.length; i++)
		this.addSingleMenuEvent(configArray[i]);

	if (!this.menuMediator.currentNode && configArray.length > 0) {
		if (isReverse)
			this.menuMediator.currentNode = configArray[configArray.length - 1];
		else
			this.menuMediator.currentNode = configArray[0];
	}
}

SimpleMenuEventDecorator.prototype.addSingleMenuEvent = function(config) {
	config.elem.onmouseout = this._mouseOut(config);
	config.elem.onmouseover = this._mouseOver(config);
	config.elem.onclick = this._mouseClick(config);
}

SimpleMenuEventDecorator.prototype._mouseOut = function(node) {
	var decorator = this;
	return function() {
		decorator.menuMediator.mouseOut(node);
	}
}

SimpleMenuEventDecorator.prototype._mouseOver = function(node) {
	var decorator = this;
	return function() {
		decorator.menuMediator.mouseOver(node);
	}
}

SimpleMenuEventDecorator.prototype._mouseClick = function(node) {
	var decorator = this;
	return function() {
		decorator.menuMediator.mouseClick(node);
	}
}
function personCustomUploadStartEventHandler(fileObj) {
    document.getElementById("uploadMsg").innerHTML += "<br />正在上传，请稍候...";
}
function myCustomUploadStartEventHandler(fileObj) {
    document.getElementById("swfInput").innerHTML = fileObj.name;
    show("uploadLoading");
}
function myCustomUploadSuccessEventHandler() {
    document.getElementById("uploadMsg").innerHTML += "<br />上传成功！";
}
function personCustomUploadErrorEventHandler() {
    document.getElementById("uploadMsg").innerHTML += "<br /><font color='red'>上传失败，请稍后再试！</font>";
}
function myCustomUploadErrorEventHandler() {
    if (isShow("uploadLoading"))
	hide("uploadLoading");
    document.getElementById("swfInput").innerHTML = "<font color='red'>上传失败，请稍后再试！</font>";
}
function myStartUpload(numFilesSelected, numFilesQueued) {
    if (numFilesQueued > 0)
	document.getElementById("uploadMsg").innerHTML = "文件进入上传队列！";
    swfu.startUpload();
}
function personFileQueueError(file, errorCode, message) {
    switch (errorCode) {
    case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
	document.getElementById("uploadMsg").innerHTML = "<font color='red'>文件个数超出所允许的上传个数，只能上传1个文件，请重新选择！</font>";
	break;
    case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
	document.getElementById("uploadMsg").innerHTML = "<font color='red'>您所选择的文件大小超过2M，只允许上传不超过2M的文件！</font>";
	break;
    case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
	document.getElementById("uploadMsg").innerHTML = "<font color='red'>文件大小为0，不能够上传！</font>";
	break;
    case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
	document.getElementById("uploadMsg").innerHTML = "<font color='red'>非法的文件类型！</font>";
	break;
    }
}
function dealGeneralEndScorePrompt() {
	var elem = document.forms[0].generalEndScore;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("generalEndScoreNotEmpty");
		if (judgeInt(value))
			hide("generalEndScoreDigit");
	}
}
function dealGeneralDiscountPrompt() {
	var elem = document.forms[0].generalDiscount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("generalDiscountNotEmpty");
		if (judgeFloat(value))
			hide("generalDiscountDigit");
	}
}
function dealSeniorEndScorePrompt() {
	var elem = document.forms[0].seniorEndScore;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("seniorEndScoreNotEmpty");
		if (judgeInt(value))
			hide("seniorEndScoreDigit");
	}
}
function dealSeniorDiscountPrompt() {
	var elem = document.forms[0].seniorDiscount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("seniorDiscountNotEmpty");
		if (judgeFloat(value))
			hide("seniorDiscountDigit");
	}
}
function dealVipEndScorePrompt() {
	var elem = document.forms[0].vipEndScore;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("vipEndScoreNotEmpty");
		if (judgeInt(value))
			hide("vipEndScoreDigit");
	}
}
function dealVipDiscountPrompt() {
	var elem = document.forms[0].vipDiscount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("vipDiscountNotEmpty");
		if (judgeFloat(value))
			hide("vipDiscountDigit");
	}
}
function dealKingDiscountPrompt() {
	var elem = document.forms[0].kingDiscount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("kingDiscountNotEmpty");
		if (judgeFloat(value))
			hide("kingDiscountDigit");
	}
}
function intelevelEdit() {
	var elem = document.forms[0].generalEndScore;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("generalEndScoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeInt(value)) {
		show("generalEndScoreDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].generalDiscount;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("generalDiscountNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeFloat(value)) {
		show("generalDiscountDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].seniorEndScore;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("seniorEndScoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeInt(value)) {
		show("seniorEndScoreDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].seniorDiscount;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("seniorDiscountNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeFloat(value)) {
		show("seniorDiscountDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].vipEndScore;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("vipEndScoreNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeInt(value)) {
		show("vipEndScoreDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].vipDiscount;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("vipDiscountNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeFloat(value)) {
		show("vipDiscountDigit");
		elem.focus();
		elem.select();
		return false;
	}
	
	var elem = document.forms[0].kingDiscount;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("kingDiscountNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (!judgeFloat(value)) {
		show("kingDiscountDigit");
		elem.focus();
		elem.select();
		return false;
	}

	return true;
}
function dealGroupNamePrompt() {
	var elem = document.forms[0].group_name;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("groupNameNotEmpty");
	}
}
function groupCreate() {
	var nameElem = document.forms[0].group_name;
	var value = nameElem.value;
	value = trimString(value);
	if (value == "") {
		show("groupNameNotEmpty");
		nameElem.focus();
		nameElem.select();
		return false;
	}
	return true;
}
function groupLeftToRightAll() {
	var leftSelect = document.forms[0].groupLeft;
	var rightSelect = document.forms[0].groupRight;
	moveOption(leftSelect, rightSelect);
}
function groupLeftToRight() {
	var leftSelect = document.forms[0].groupLeft;
	var rightSelect = document.forms[0].groupRight;
	moveOption(leftSelect, rightSelect, true);
}
function groupRightToLeftAll() {
	var rightSelect = document.forms[0].groupRight;
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
		rightSelect.remove(i);
}
function groupRightToLeft() {
	var rightSelect = document.forms[0].groupRight;
	var idxArray = [];
	for (var i = rightSelect.options.length - 1; i >= 0; i--)
	if (rightSelect.options[i].selected)
		idxArray.push(i);
	for (idx in idxArray)
		rightSelect.remove(idxArray[idx]);
}
function setRuleGroup() {
	var rightSelect = document.forms[0].groupRight;
	var valueArray = [];
	for (var i = 0; i < rightSelect.options.length; i++)
		valueArray.push(rightSelect.options[i].value);
	document.forms[0].group_ids.value = valueArray.join(",");
}
function dealRuleNamePrompt() {
	var elem = document.forms[0].rule_name;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		hide("ruleNameNotEmpty");
	}
}
function dealRuleMinTradeCountPrompt() {
	var elem = document.forms[0].min_trade_count;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value))
			hide("minTradeCountDigit");
	}
}
function dealRuleMaxTradeCountPrompt() {
	var elem = document.forms[0].max_trade_count;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value)) {
			hide("maxTradeCountDigit");
		
		    var minElem = document.forms[0].min_trade_count;
        	var minValue = minElem.value;
        	if (minValue) {
        	    if (judgeInt(minValue)) {
        	        if (parseFloat(minValue) <= parseFloat(value))
        	            hide("maxTradeCountInvalid");
        	    }
        	}
        }
	}
}
function dealRuleMinTradeAmountPrompt() {
	var elem = document.forms[0].min_trade_amount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeFloat(value))
			hide("minTradeAmountDigit");
	}
}
function dealRuleMaxTradeAmountPrompt() {
	var elem = document.forms[0].max_trade_amount;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeFloat(value)) {
			hide("maxTradeAmountDigit");
		
		    var minElem = document.forms[0].min_trade_amount;
        	var minValue = minElem.value;
        	if (minValue) {
        	    if (judgeFloat(minValue)) {
        	        if (parseFloat(minValue) <= parseFloat(value))
        	            hide("maxTradeAmountInvalid");
        	    }
        	}
        }
	}
}
function dealMaxLastTradeTimePrompt() {
	var elem = document.forms[0].max_last_trade_time;
	var value = elem.value;
	value = trimString(value);
	if (value) {
	    var minElem = document.forms[0].min_last_trade_time;
    	var minValue = minElem.value;
    	if (minValue) {
	        if (parseFloat(minValue) <= parseFloat(value))
	            hide("maxLastTradeTimeInvalid");
    	}
	}
}
function dealMinAvgPricePrompt() {
	var elem = document.forms[0].min_avg_price;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeFloat(value))
			hide("minAvgPriceDigit");
	}
}
function dealMaxAvgPricePrompt() {
	var elem = document.forms[0].max_avg_price;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeFloat(value)) {
			hide("maxAvgPriceDigit");
		
		    var minElem = document.forms[0].min_avg_price;
        	var minValue = minElem.value;
        	if (minValue) {
        	    if (judgeFloat(minValue)) {
        	        if (parseFloat(minValue) <= parseFloat(value))
        	            hide("maxAvgPriceInvalid");
        	    }
        	}
        }
	}
}
function dealMinItemNumPrompt() {
	var elem = document.forms[0].min_item_num;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value))
			hide("minItemNumDigit");
	}
}
function dealMaxItemNumPrompt() {
	var elem = document.forms[0].max_item_num;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value)) {
			hide("maxItemNumDigit");
		
		    var minElem = document.forms[0].min_item_num;
        	var minValue = minElem.value;
        	if (minValue) {
        	    if (judgeInt(minValue)) {
        	        if (parseFloat(minValue) <= parseFloat(value))
        	            hide("maxItemNumInvalid");
        	    }
        	}
        }
	}
}
function dealMinCloseTradeNumPrompt() {
	var elem = document.forms[0].min_close_trade_num;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value))
			hide("minCloseTradeNumDigit");
	}
}
function dealMaxCloseTradeNumPrompt() {
	var elem = document.forms[0].max_close_trade_num;
	var value = elem.value;
	value = trimString(value);
	if (value) {
		if (judgeInt(value)) {
			hide("maxCloseTradeNumDigit");
		
		    var minElem = document.forms[0].min_close_trade_num;
        	var minValue = minElem.value;
        	if (minValue) {
        	    if (judgeInt(minValue)) {
        	        if (parseFloat(minValue) <= parseFloat(value))
        	            hide("maxCloseTradeNumInvalid");
        	    }
        	}
        }
	}
}
function ruleCreate() {
	var elem = document.forms[0].rule_name;
	if (elem) {
		var value = elem.value;
		value = trimString(value);
		if (!value) {
			show("ruleNameNotEmpty");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].min_trade_count;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("minTradeCountDigit");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].max_trade_count;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("maxTradeCountDigit");
			elem.focus();
			elem.select();
			return false;
	    } else if (value) {
			var minElem = document.forms[0].min_trade_count;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
				    hide("maxTradeCountDigit");
					show("maxTradeCountInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
		}
	}
	var elem = document.forms[0].min_trade_amount;
	if (elem) {
		var value = elem.value;
		if (value && !judgeFloat(value)) {
			show("minTradeAmountDigit");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].max_trade_amount;
	if (elem) {
		var value = elem.value;
		if (value && !judgeFloat(value)) {
			show("maxTradeAmountDigit");
			elem.focus();
			elem.select();
			return false;
	    } else if (value) {
			var minElem = document.forms[0].min_trade_amount;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
					hide("maxTradeAmountDigit");
					show("maxTradeAmountInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
		}
	}
	var elem = document.forms[0].max_last_trade_time;
	if (elem) {
		var value = elem.value;
		if (value) {
			var minElem = document.forms[0].min_last_trade_time;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
					show("maxLastTradeTimeInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
	    }
	}
	var elem = document.forms[0].min_avg_price;
	if (elem) {
		var value = elem.value;
		if (value && !judgeFloat(value)) {
			show("minAvgPriceDigit");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].max_avg_price;
	if (elem) {
		var value = elem.value;
		if (value && !judgeFloat(value)) {
			show("maxAvgPriceDigit");
			elem.focus();
			elem.select();
			return false;
	    } else if (value) {
			var minElem = document.forms[0].min_avg_price;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
					hide("maxAvgPriceDigit");
					show("maxAvgPriceInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
		}
	}
	var elem = document.forms[0].min_item_num;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("minItemNumDigit");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].max_item_num;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("maxItemNumDigit");
			elem.focus();
			elem.select();
			return false;
	    } else if (value) {
			var minElem = document.forms[0].min_item_num;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
					hide("maxItemNumDigit");
					show("maxItemNumInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
		}
	}
	var elem = document.forms[0].min_close_trade_num;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("minCloseTradeNumDigit");
			elem.focus();
			elem.select();
			return false;
	    }
	}
	var elem = document.forms[0].max_close_trade_num;
	if (elem) {
		var value = elem.value;
		if (value && !judgeInt(value)) {
			show("maxCloseTradeNumDigit");
			elem.focus();
			elem.select();
			return false;
	    } else if (value) {
			var minElem = document.forms[0].min_close_trade_num;
			if (minElem) {
				if (parseFloat(minElem.value) > parseFloat(elem.value)) {
					hide("maxCloseTradeNumDigit");
					show("maxCloseTradeNumInvalid");
					elem.focus();
					elem.select();
					return false;
				}
		    }
		}
	}

	setRuleGroup();
	return true;
}
function evaluationComment1() {
	if (!isShow("commentDiv1")) {
		show("commentDiv1");
	} else {
		if (comment1Submit())
			document.forms["commentForm1"].submit();
	}
}
function dealComment1Prompt() {
	var elem = document.forms["commentForm1"].comment1;
	var value = elem.value;
	value = trimString(value);
	if (value)
		hide("comment1NotEmpty");
	if (value.length <= 500)
		hide("comment1LengthNotValid");
}
function dealCommentPrompt() {
	var elem = document.forms[0].comment;
	var value = elem.value;
	value = trimString(value);
	if (value)
		hide("commentNotEmpty");
	if (value.length <= 500)
		hide("commentLengthNotValid");
}
function comment1Submit() {
	var elem = document.forms["commentForm1"].comment1;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("comment1NotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 500) {
		show("comment1LengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function evaluationComment2() {
	if (!isShow("commentDiv2")) {
		show("commentDiv2");
	} else {
		if (comment2Submit())
			document.forms["commentForm2"].submit();
	}
}
function dealComment2Prompt() {
	var elem = document.forms["commentForm2"].comment2;
	var value = elem.value;
	value = trimString(value);
	if (value)
		hide("comment2NotEmpty");
	if (value.length <= 500)
		hide("comment2LengthNotValid");
}
function comment2Submit() {
	var elem = document.forms["commentForm2"].comment2;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("comment2NotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 500) {
		show("comment2LengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function dealEvaluationContentPrompt() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (value != "")
		hide("contentNotEmpty");
	if (value.length <= 500)
		hide("contentLengthNotValid");
}
function evaluationCreate(type) {
	if (type == 7) {
		var elem = document.getElementById("good");
		if (!elem.checked) {
			var elem = document.forms[0].content;
			var value = elem.value;
			value = trimString(value);
			if (value == "") {
				show("contentNotEmpty");
				elem.focus();
				elem.select();
				return false;
			}
		}
	}
	var elem = document.forms[0].content;
	var value = elem.value;
	if (value.length > 500) {
		show("contentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function selectEvaluationType(selectValue) {
	var elem = document.forms[0].result;
	for(var i = 0; i < elem.length; i++) {
		if (elem[i].value == selectValue) {
			elem[i].checked = true;
			break;
		}
	}
}
function selectDisType(selectValue) {
	var li = document.forms[0].disType;
	for(var i = 0; i < li.length; i++) {
		if (li[i].value == selectValue) {
			li[i].checked = true;
			break;
		}
	}
}
function selectMode(selectValue) {
	var li = document.forms[0].mode;
	for(var i = 0; i < li.length; i++) {
		if (li[i].value == selectValue) {
			li[i].checked = true;
			break;
		}
	}
}
function distManaCreate() {
	setUserRole();
	if (document.getElementById("disType2").checked && !document.forms[0].role.value) {
		show("roleNotEmpty");
		return false;
	}
	return true;
}
function changeDisType() {
	if (document.getElementById("disType2").checked)
		show("disTypeDiv");
	else
		hide("disTypeDiv");
}
function chatAvoidSettingCreate() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("contentNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 2000) {
		show("contentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function dealChatAvoidSettingContentPrompt() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("contentNotEmpty");
	if (value.length <= 500)
		hide("contentLengthNotValid");
}
function chatCustomerClassifyCreate() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("contentNotEmpty");
		elem.focus();
		elem.select();
		return false;
	} else if (value.length > 2000) {
		show("contentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function dealCustomerClassifyContentPrompt() {
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (!value == "")
		hide("contentNotEmpty");
	if (value.length <= 500)
		hide("contentLengthNotValid");
}
function customerClassifyCreate() {
	var elem = document.forms[0].name;
	var value = elem.value;
	value = trimString(value);
	if (!value) {
		show("nameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function chatAvoidExcelSubmit() {
	document.forms['excelForm'].userId.value = document.forms[0].userId.value;
	document.forms['excelForm'].toId.value = document.forms[0].toId.value;
	document.forms['excelForm'].beginTime.value = document.forms[0].beginTime.value;
	document.forms['excelForm'].endTime.value = document.forms[0].endTime.value;
	document.forms['excelForm'].content.value = document.forms[0].content.value;
	document.forms['excelForm'].submit();
}
function gotoChatRecordForm(id) {
	document.forms['chatRecordForm'].customerChatClassifyId.value = id;
	document.forms['chatRecordForm'].submit();
}
// complain create
function projectCreate() {
	var nickElem = document.forms[0].name;
	var value = nickElem.value;
	value = trimString(value);
	if (value == "") {
		show("nameNotEmpty");
		nickElem.focus();
		nickElem.select();
		return false;
	}
	return true;
}
function dealSourceCodePrompt() {
	var nameElem = document.forms[0].content;
	var value = nameElem.value;
	value = trimString(value);
	if (!value == "")
		hide("sourceCodeNotEmpty");
}
function sourceCodeCreate() {
	var elem = document.forms[0].name;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("nameNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	var elem = document.forms[0].comment;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("commentNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	if (value.length > 500) {
		show("commentLengthNotValid");
		elem.focus();
		elem.select();
		return false;
	}
	var elem = document.forms[0].content;
	var value = elem.value;
	value = trimString(value);
	if (value == "") {
		show("sourceCodeNotEmpty");
		elem.focus();
		elem.select();
		return false;
	}
	return true;
}
function replaceSourceCode() {
	var array = [];
	for (var i = 0; i < 100; i++) {
		var origElem = document.getElementById("orig" + i);
		var replElem = document.getElementById("repl" + i);
		if (origElem) {
			array.push({'orig': origElem.value, 'repl': replElem.value});
		}
	}
	var content = document.getElementById("content").value;
	for (var i = 0; i < array.length; i++) {
		content = content.replace(new RegExp(array[i]['orig'], 'g'), array[i]['repl'])
	}
	document.getElementById("replResult").value = content;
}

